From: Benjamin Otte Date: Sat, 4 Nov 2017 22:58:17 +0000 (+0100) Subject: gdk: Use G_N_ELEMENTS() when iterating over constant arrays X-Git-Tag: archive/raspbian/4.4.1+ds1-2+rpi1^2~18^2~23^2~876 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https://%22%22/%22http:/www.example.com/cgi/%22https:/%22%22?a=commitdiff_plain;h=7e137b25245af2c086d40faba603351fa4f1006c;p=gtk4.git gdk: Use G_N_ELEMENTS() when iterating over constant arrays And do that everywhere. Because if we don't, we're gonna crash sometimes. --- diff --git a/gdk/wayland/gdkcursor-wayland.c b/gdk/wayland/gdkcursor-wayland.c index a2ad42b518..925e5b1fbb 100644 --- a/gdk/wayland/gdkcursor-wayland.c +++ b/gdk/wayland/gdkcursor-wayland.c @@ -99,8 +99,7 @@ static const struct { { "nesw-resize", "fd_double_arrow" }, { "nwse-resize", "bd_double_arrow" }, { "zoom-in", "left_ptr" }, - { "zoom-out", "left_ptr" }, - { NULL, NULL } + { "zoom-out", "left_ptr" } }; static const gchar * @@ -108,7 +107,7 @@ name_fallback (const gchar *name) { gint i; - for (i = 0; name_map[i].css_name; i++) + for (i = 0; i < G_N_ELEMENTS (name_map); i++) { if (g_str_equal (name_map[i].css_name, name)) return name_map[i].traditional_name; diff --git a/gdk/x11/gdkcursor-x11.c b/gdk/x11/gdkcursor-x11.c index 90e6020d64..38f3dbf925 100644 --- a/gdk/x11/gdkcursor-x11.c +++ b/gdk/x11/gdkcursor-x11.c @@ -140,8 +140,7 @@ static const struct { { "nesw-resize", "fd_double_arrow", XC_X_cursor }, { "nwse-resize", "bd_double_arrow", XC_X_cursor }, { "zoom-in", "left_ptr", XC_draped_box }, - { "zoom-out", "left_ptr", XC_draped_box }, - { NULL, NULL, XC_X_cursor } + { "zoom-out", "left_ptr", XC_draped_box } }; #ifdef HAVE_XCURSOR